<?xml version="1.0" encoding="iso-8859-1" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content=
    "application/xhtml+xml; charset=iso-8859-1" />
    <title>
      Python-3.8.2
    </title>
    <link rel="stylesheet" type="text/css" href="../stylesheets/lfs.css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.78.1" />
    <link rel="stylesheet" href="../stylesheets/lfs-print.css" type=
    "text/css" media="print" />
  </head>
  <body class="blfs" id="blfs-2020-04-02">
    <div class="navheader">
      <h4>
        Beyond Linux<sup>�</sup> From Scratch <span class="phrase">(System
        V</span> Edition) - Version 2020-04-02
      </h4>
      <h3>
        Chapter&nbsp;13.&nbsp;Programming
      </h3>
      <ul>
        <li class="prev">
          <a accesskey="p" href="python2.html" title="Python-2.7.17">Prev</a>
          <p>
            Python-2.7.17
          </p>
        </li>
        <li class="next">
          <a accesskey="n" href="python-modules.html" title=
          "Python Modules">Next</a>
          <p>
            Python Modules
          </p>
        </li>
        <li class="up">
          <a accesskey="u" href="prog.html" title=
          "Chapter&nbsp;13.&nbsp;Programming">Up</a>
        </li>
        <li class="home">
          <a accesskey="h" href="../index.html" title=
          "Beyond Linux� From Scratch     (System V Edition) - Version 2020-04-02">
          Home</a>
        </li>
      </ul>
    </div>
    <div class="sect1" lang="en" xml:lang="en">
      <h1 class="sect1">
        <a id="python3" name="python3"></a>Python-3.8.2
      </h1>
      <div class="package" lang="en" xml:lang="en">
        <h2 class="sect2">
          Introduction to Python 3
        </h2>
        <p>
          The <span class="application">Python 3</span> package contains the
          <span class="application">Python</span> development environment.
          This is useful for object-oriented programming, writing scripts,
          prototyping large programs or developing entire applications.
        </p>
        <div class="admon note">
          <img alt="[Note]" src="../images/note.png" />
          <h3>
            Note
          </h3>
          <p>
            <span class="application">Python 3</span> was installed in LFS.
            The only reason to rebuild it here is if optional modules are
            needed.
          </p>
        </div>
        <p>
          This package is known to build and work properly using an LFS-9.1
          platform.
        </p>
        <h3>
          Package Information
        </h3>
        <div class="itemizedlist">
          <ul class="compact">
            <li class="listitem">
              <p>
                Download (HTTP): <a class="ulink" href=
                "https://www.python.org/ftp/python/3.8.2/Python-3.8.2.tar.xz">
                https://www.python.org/ftp/python/3.8.2/Python-3.8.2.tar.xz</a>
              </p>
            </li>
            <li class="listitem">
              <p>
                Download MD5 sum: e9d6ebc92183a177b8e8a58cad5b8d67
              </p>
            </li>
            <li class="listitem">
              <p>
                Download size: 17 MB
              </p>
            </li>
            <li class="listitem">
              <p>
                Estimated disk space required: 193 MB (add 27 MB for tests)
              </p>
            </li>
            <li class="listitem">
              <p>
                Estimated build time: 0.5 SBU (using parallelism=4; add 1.6
                SBU for tests, including rebuilding)
              </p>
            </li>
          </ul>
        </div>
        <h3>
          Python 3 Dependencies
        </h3>
        <h4>
          Optional
        </h4>
        <p class="optional">
          <a class="xref" href="bluez.html" title=
          "BlueZ-5.54">BlueZ-5.54</a>, <a class="xref" href="gdb.html" title=
          "GDB-9.1">GDB-9.1</a> (required for some tests), <a class="xref"
          href="valgrind.html" title="Valgrind-3.15.0">Valgrind-3.15.0</a>,
          and <a class="ulink" href=
          "http://www.bytereef.org/mpdecimal">libmpdec</a>
        </p>
        <h4>
          Optional (For Additional Modules)
        </h4>
        <p class="optional">
          <a class="xref" href="../server/db.html" title=
          "Berkeley DB-5.3.28">Berkeley DB-5.3.28</a>, <a class="xref" href=
          "../server/sqlite.html" title="SQLite-3.31.1">SQLite-3.31.1</a>,
          and <a class="xref" href="tk.html" title="Tk-8.6.10">Tk-8.6.10</a>
        </p>
        <p class="usernotes">
          User Notes: <a class="ulink" href=
          "http://wiki.linuxfromscratch.org/blfs/wiki/Python3">http://wiki.linuxfromscratch.org/blfs/wiki/Python3</a>
        </p>
      </div>
      <div class="installation" lang="en" xml:lang="en">
        <h2 class="sect2">
          Installation of Python 3
        </h2>
        <p>
          Install <span class="application">Python 3</span> by running the
          following commands:
        </p>
        <pre class="userinput">
<kbd class="command">CXX="/usr/bin/g++"              \
./configure --prefix=/usr       \
            --enable-shared     \
            --with-system-expat \
            --with-system-ffi   \
            --with-ensurepip=yes &amp;&amp;
make</kbd>
</pre>
        <p>
          The test suite must be run separately, using an X terminal (see
          below).
        </p>
        <p>
          Now, as the <code class="systemitem">root</code> user:
        </p>
        <pre class="root">
<kbd class="command">make install &amp;&amp;

chmod -v 755 /usr/lib/libpython3.8.so &amp;&amp;
chmod -v 755 /usr/lib/libpython3.so</kbd>
</pre>
        <p>
          The test suite must be run separately from the build, either before
          or after the package is built and installed. Do not run
          <span class="command"><strong>make install</strong></span> after
          running the test suite. To build and install the package, you need
          to start with a fresh or clean source tree. For the tests, you also
          need a clean source code, so either start by removing the source
          code directory and starting over, by uncompressing the source
          tarball or by running <span class="command"><strong>make
          clean</strong></span>. Then configure again, adding <span class=
          "quote">&ldquo;<span class=
          "quote">--with-pydebug</span>&rdquo;</span> to the <span class=
          "command"><strong>configure</strong></span> switches above, run
          <span class="command"><strong>make</strong></span>, then
          <span class="command"><strong>make test</strong></span>. Remember
          that tests must be executed using an X terminal. The test SBU
          highly depends on the speed of the internet connection. The
          test_sqlite test is known to fail.
        </p>
      </div>
      <div class="commands" lang="en" xml:lang="en">
        <h2 class="sect2">
          Command Explanations
        </h2>
        <p>
          <span class="command"><strong>CXX="/usr/bin/g++" ./configure
          ...</strong></span>: Avoid an annoying message during
          configuration.
        </p>
        <p>
          <em class="parameter"><code>--with-system-expat</code></em>: This
          switch enables linking against the system version of <span class=
          "application">Expat</span>.
        </p>
        <p>
          <em class="parameter"><code>--with-system-ffi</code></em>: This
          switch enables linking against system version of <span class=
          "application">libffi</span>.
        </p>
        <p>
          <em class="parameter"><code>--with-ensurepip=yes</code></em> : This
          switch enables building <span class=
          "command"><strong>pip</strong></span> and <span class=
          "command"><strong>setuptools</strong></span> packaging programs.
          <span class="command"><strong>setuptools</strong></span> is needed
          for building some Python modules.
        </p>
        <p>
          <code class="option">--with-dbmliborder=bdb:gdbm:ndbm</code>: Use
          this switch if you want to build <span class=
          "application">Python</span> DBM Module against <span class=
          "application">Berkeley DB</span> instead of <span class=
          "application">GDBM</span>.
        </p>
        <p>
          <code class="option">--enable-optimization</code>: Use this switch
          if you want to enable <span class=
          "emphasis"><em>expensive</em></span> optimizations (i.e. Profile
          Guided Optimizations). This adds around 20 SBU, but can
          <span class="emphasis"><em>slightly</em></span> speed up some uses,
          such as using <span class="application">Sphinx</span> for creating
          documentation, or use of <span class="application">Python3</span>
          scripts.
        </p>
        <p>
          <code class="option">--with-lto</code>: This optional switch
          enables thick Link Time Optimization. Unusually, it creates a much
          larger <code class=
          "filename">/usr/lib/python3.8/config-3.8-&lt;arch&gt;-linux-gnu/libpython3.8.a</code>
          with a small increase in the time to compile <span class=
          "application">Python</span>. Run-time results do not appear to show
          any benefit from doing this.
        </p>
        <p>
          <span class="command"><strong>chmod ...</strong></span>: Fix
          permissions for shared libraries to be consistent with other
          libraries.
        </p>
      </div>
      <div class="configuration" lang="en" xml:lang="en">
        <h2 class="sect2">
          Configuring Python 3
        </h2>
        <p>
          In order for <span class="command"><strong>python3</strong></span>
          to find the installed documentation, create the following version
          independent symlink:
        </p>
        <pre class="root">
<kbd class="command">ln -svfn python-3.8.2 /usr/share/doc/python-3</kbd>
</pre>
        <p>
          and add the following environment variable to the individual user's
          or system's profile:
        </p>
        <pre class="root">
<kbd class="command">export PYTHONDOCS=/usr/share/doc/python-3/html</kbd>
</pre>
      </div>
      <div class="content" lang="en" xml:lang="en">
        <h2 class="sect2">
          Contents
        </h2>
        <div class="segmentedlist">
          <div class="seglistitem">
            <div class="seg">
              <strong class="segtitle">Installed Programs:</strong>
              <span class="segbody">2to3 (symlink) and 2to3-3.8, easy_install
              (symlink) and easy_install-3.8, idle3 (symlink) and idle3.8,
              pip3 (symlink) and pip3.8, pydoc3 (symlink) and pydoc3.8,
              python3 (symlink); python3.8, and python3-config (symlink) and
              python3.8-config</span>
            </div>
            <div class="seg">
              <strong class="segtitle">Installed Libraries:</strong>
              <span class="segbody">libpython3.8.so and libpython3.so</span>
            </div>
            <div class="seg">
              <strong class="segtitle">Installed Directories:</strong>
              <span class="segbody">/usr/include/python3.8,
              /usr/lib/python3.8, and /usr/share/doc/python-3.8.2</span>
            </div>
          </div>
        </div>
        <div class="variablelist">
          <h3>
            Short Descriptions
          </h3>
          <table border="0" class="variablelist">
            <colgroup>
              <col align="left" valign="top" />
              <col />
            </colgroup>
            <tbody>
              <tr>
                <td>
                  <p>
                    <a id="easy_install" name="easy_install"></a><span class=
                    "term"><span class=
                    "command"><strong>easy_install</strong></span></span>
                  </p>
                </td>
                <td>
                  <p>
                    is a frontend to pip3 to make it easier to configure
                    python modules through the PIP package manager.
                  </p>
                </td>
              </tr>
              <tr>
                <td>
                  <p>
                    <a id="idle3" name="idle3"></a><span class=
                    "term"><span class=
                    "command"><strong>idle3</strong></span></span>
                  </p>
                </td>
                <td>
                  <p>
                    is a wrapper script that opens a <span class=
                    "application">Python</span> aware GUI editor. For this
                    script to run, you must have installed <span class=
                    "application">Tk</span> before Python so that the Tkinter
                    Python module is built.
                  </p>
                </td>
              </tr>
              <tr>
                <td>
                  <p>
                    <a id="pydoc3" name="pydoc3"></a><span class=
                    "term"><span class=
                    "command"><strong>pydoc3</strong></span></span>
                  </p>
                </td>
                <td>
                  <p>
                    is the <span class="application">Python</span>
                    documentation tool.
                  </p>
                </td>
              </tr>
              <tr>
                <td>
                  <p>
                    <a id="python3-prog" name="python3-prog"></a><span class=
                    "term"><span class=
                    "command"><strong>python3</strong></span></span>
                  </p>
                </td>
                <td>
                  <p>
                    is an interpreted, interactive, object-oriented
                    programming language.
                  </p>
                </td>
              </tr>
              <tr>
                <td>
                  <p>
                    <a id="python-ver" name="python-ver"></a><span class=
                    "term"><span class=
                    "command"><strong>python3.8</strong></span></span>
                  </p>
                </td>
                <td>
                  <p>
                    is a version-specific name for the <span class=
                    "command"><strong>python</strong></span> program.
                  </p>
                </td>
              </tr>
            </tbody>
          </table>
        </div>
      </div>
      <p class="updated">
        Last updated on 2020-03-17 00:27:21 -0500
      </p>
    </div>
    <div class="navfooter">
      <ul>
        <li class="prev">
          <a accesskey="p" href="python2.html" title="Python-2.7.17">Prev</a>
          <p>
            Python-2.7.17
          </p>
        </li>
        <li class="next">
          <a accesskey="n" href="python-modules.html" title=
          "Python Modules">Next</a>
          <p>
            Python Modules
          </p>
        </li>
        <li class="up">
          <a accesskey="u" href="prog.html" title=
          "Chapter&nbsp;13.&nbsp;Programming">Up</a>
        </li>
        <li class="home">
          <a accesskey="h" href="../index.html" title=
          "Beyond Linux� From Scratch     (System V Edition) - Version 2020-04-02">
          Home</a>
        </li>
      </ul>
    </div>
  </body>
</html>
